import request from '@/utils/request'
// ====================================
// ====================================
//  Flows api
// ====================================
// ====================================
/**
 * 获取对象列表
 */
export function list(params) {
  return request({
    url: '/flows',
    method: 'get',
    params
  })
}

export function echarts(params) {
  return request({
    url: '/flows/echarts',
    method: 'get',
    params
  })
}
/**
 * 获取登录用户的列表，通过JWT token
 */
export function mine(params) {
  return request({
    url: '/flows/mine',
    method: 'get',
    params
  })
}
/**
 * 通过ID获取对象
 */
export function get(id) {
  return request({
    url: `/flows/${id}`,
    method: 'get'
  })
}
/**
 * 新增前查询
 */
export function newly(id) {
  return request({
    url: '/flows/new',
    method: 'get'
  })
}
/**
 * 添加对象
 */
export function create(data) {
  return request({
    url: '/flows',
    method: 'post',
    data
  })
}
/**
 * 编辑前查询
 */
export function edit(id) {
  return request({
    url: `/flows/${id}/edit`,
    method: 'get'
  })
}

/**
 * 更新对象
 */
export function update(id, data) {
  return request({
    url: `/flows/${id}`,
    method: 'put',
    data
  })
}
/**
 * 删除对象
 */
export function remove(id) {
  return request({
    url: `/flows/${id}`,
    method: 'delete'
  })
}

export default {
  list,
  mine,
  get,
  newly,
  create,
  edit,
  update,
  echarts,
  remove
}
